<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <title>DataBoot</title>
  <!--本地引入 luckysheet-->
<!--  <link rel='stylesheet' href='./plugins/css/pluginsCss.css' />
  <link rel='stylesheet' href='./plugins/plugins.css' />
  <link rel='stylesheet' href='./css/luckysheet.css' />
  <link rel='stylesheet' href='./assets/iconfont/iconfont.css' />
  <script src="./plugins/js/plugin.js"></script>
  <script src="./luckysheet.umd.js"></script>-->

  <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/css/pluginsCss.css' />
  <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/plugins.css' />
  <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/css/luckysheet.css' />
  <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/assets/iconfont/iconfont.css' />
  <script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/js/plugin.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/luckysheet.umd.js"></script>
  <style>
    .luckysheet-share-logo {
      height: 32px;
      width: 152px;
      z-index: 1;
      background-image:url("");
    }
    .luckysheet_info_detail_update {
      color: #ffff;
      font-size: 12px;
      margin-left: 15px;
    }
    .luckysheet_info_detail_save {
      color: #ffff;
      font-size: 12px;
      margin: 0 5px;
    }
  </style>
</head>

<body>
<div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:100%;left: 0px;top: 0px;"></div>


</body>
<script>
  var url = window.location.host;
  var baseUrl = "";
  //alert(url)
  if(url == "localhost:3000" || url.indexOf("3000") >=0){
    baseUrl = "http://localhost:8080/boot";
  }else if(url == "boot-stg.huiliu365.cn"){
    baseUrl = "http://stg-ing-data-boot.c97a1464513cf4ad79883ac2d45d18ca5.cn-beijing.alicontainer.com/boot";
  }else if(url == "boot.huiliu365.com"){
    baseUrl = "http://data-boot.ca82465120fe648b1a886b5a45c5c151b.cn-beijing.alicontainer.com/boot";
  }
//alert(baseUrl)
    //loadUrl是返回luckysheet 数据的后台api接口
    var options = {
        container: 'luckysheet', //luckysheet为容器id
        title: 'RPA规则录入', // 设定表格名称
        lang: 'zh', // 设定表格语言
        allowEdit: true,//作用：是否允许前台编辑
        showinfobar: true,//作用：是否显示顶部信息栏
        showsheetbar: false,
        showtoolbar:false,    // 是否显示工具栏
        allowCopy:false,   // 允许复制
        myFolderUrl: "",//作用：左上角<返回按钮的链接
        functionButton: '<button id="" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 185px;" onclick="saveData()">保存</button>',
        loadUrl: baseUrl+"/ai/rule/getDefForProperties",
        data: [
            {
                "name": "RPA规则", //工作表名称
                "color": "", //工作表颜色
                "index": 0, //工作表索引
                "status": 1, //激活状态
                "order": 0, //工作表的下标
                "hide": 1,//是否隐藏
                "row": 18, //行数
                "column": 3, //列数
                //"defaultRowHeight": 19, //自定义行高
                "defaultColWidth": 123, //自定义列宽
                "celldata": [], //初始化使用的单元格数据
                "scrollLeft": 0, //左右滚动条位置
                "scrollTop": 315, //上下滚动条位置
                "luckysheet_select_save": [], //选中的区域
                "calcChain": [],//公式链
                "isPivotTable":false,//是否数据透视表
                "pivotTable":{},//数据透视表设置
                "filter_select": {},//筛选范围
                "filter": null,//筛选配置
                "luckysheet_alternateformat_save": [], //交替颜色
                "luckysheet_alternateformat_save_modelCustom": [], //自定义交替颜色
                "luckysheet_conditionformat_save": {},//条件格式
                "frozen": {}, //冻结行列配置
                "chart": [], //图表配置
                "zoomRatio":1, // 缩放比例
                "image":[], //图片
                "showGridLines": 1, //是否显示网格线
                "dataVerification":{} //数据验证配置
            }
        ]

    }
    $(function () {
        //配置项
        luckysheet.create(options)
    })

    function saveData() {
        //这里你要自己写个后台接口，处理上传上来的Excel数据，用post传输。我用的是Java后台处理导出！这里只是写了post请求的写法
        console.log("luckysheet.getAllSheets() = " + JSON.stringify(luckysheet.getAllSheets()))
        var form = document.createElement("form");
        form.method = 'post';
        form.action = baseUrl+'/ai/rule/saveAllRule';
        form.style = 'display:none';
        form.enctype = 'multipart/form-data';
        document.body.appendChild(form);
        var newElement = document.createElement("textarea");
        newElement.setAttribute("type","hidden");
        newElement.name = "exceldata";
        newElement.value = JSON.stringify(luckysheet.getAllSheets());
        form.appendChild(newElement);
        form.submit(function(e){
        });
      window.location.href = "sucess.html";

    }
</script>

</html>